<template>
  <div class="home">
    <header>
      <Header />
      <ly-tab v-model="value" :items="items" @change="getId" />
    </header>
    <main v-for="item in dataList" :key="item.id">
      <Swiper v-if="item.type === 'swiperList'" :swiperList="item.data" />
      <Nav v-if="item.type === 'iconList'" :iconList="item.data" />
      <Headeline v-if="item.type === 'lineList'" :lineList="item.data" />
      <Recommend
        v-if="item.type === 'recommendList'"
        :recommendList="item.data"
      />
      <Like v-if="item.type === 'likeList'" :likeList="item.data" />
      <Dhp v-if="item.type === 'dhpAdList'" :adList="item"></Dhp>
    </main>
    <Tabbar />
  </div>
</template>

<script>
import Tabbar from "@/components/common/Tabbar.vue";
import Header from "@/components/home/Header.vue";
import Swiper from "@/components/home/Swiper.vue";
import Nav from "@/components/home/Nav.vue";
import Headeline from "@/components/home/Headeline.vue";
import Recommend from "@/components/home/Recommend.vue";
import Like from "@/components/home/Like.vue";
import Dhp from "@/components/navList/Dhp.vue";
import { getData, getList } from "@/utils/api/api";
export default {
  name: "HomeView",
  components: {
    Tabbar,
    Header,
    Swiper,
    Nav,
    Headeline,
    Recommend,
    Like,
    Dhp,
  },
  data() {
    return {
      value: 0,
      items: [],
      dataList: [],
    };
  },
  beforeMount() {
    getList().then((res) => {
      this.items = res.data.data.topBar;
    });
    this.getId();
  },
  methods: {
    getId() {
      // console.log(this.value);
      getData(this.value).then((res) => {
        this.dataList = res.data.data.data;
      });
    },
  },
};
</script>
<style lang="less" scoped>
.home {
  header {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 999;
  }
}
</style>
